@extends("admin.common.admin")

<title>添加权限 - 添加权限管理 - H-ui.admin v3.1</title>
@section("cnt")
    <nav class="breadcrumb">
        <i class="Hui-iconfont">&#xe67f;</i>
        首页
        <span class="c-gray en">&gt;</span>
        添加权限
        <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" >
            <i class="Hui-iconfont">&#xe68f;</i>
        </a>
    </nav>


    <article class="page-container">
        @include("admin.common.msg")
        <form class="form form-horizontal" id="form-admin-add" method="post" action="{{ route("admin.node.store") }}">
            @csrf
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>权限名称：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="{{ old("node_name") }}" placeholder="" id="node_name" name="node_name">
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>是否菜单：</label>
                <div class="formControls col-xs-8 col-sm-9 skin-minimal">
                    <div class="radio-box">
                        <input name="is_menu" type="radio" value="0" id="is_menu-1" checked>
                        <label for="sex-1">否</label>
                    </div>
                    <div class="radio-box">
                        <input type="radio" id="is_menu-2" value="1" name="is_menu">
                        <label for="sex-2">是</label>
                    </div>
                </div>
            </div>
            <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">上级权限:</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <span class="select-box" style="width:150px;">
                        <select class="select" name="pid" id="pid" size="1">
                            <option value="0">==顶级权限==</option>
                            @foreach($data as $item)
                            <option value="{{ $item->id }}">=={{ $item->node_name }}==</option>
                            @endforeach
                        </select>
                    </span>
                </div>
            </div>

            <div class="row cl " id="routename" style="display: none">
                <label class="form-label col-xs-4 col-sm-3">路由名称：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="{{ old("route_name") }}" placeholder="" id="route_name" name="route_name">
                </div>
            </div>
            <div class="row cl">

                <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                    <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
                </div>
            </div>
        </form>
    </article>
@endsection
@section("js")
    <script type="text/javascript">
        let nenu = 0;
        $("#pid").change(function () {
            nenu = Number($(this).val());
            if( nenu > 0){
                $("#routename").slideDown();
            }else{
                $("#routename").slideUp();
            }
        })
        $(function(){


            $('.skin-minimal input').iCheck({
                checkboxClass: 'icheckbox-blue',
                radioClass: 'iradio-blue',
                increaseArea: '20%'
            });
            $("#form-admin-add").validate({
                rules:{
                    node_namse:{
                        required:true,
                        minlength:2
                    },
                    // route_name:{
                    //     required:true,
                    //     maxlength:2
                    // },
                },
                onkeyup:false,
                success:"valid",
                submitHandler:function(form){
                    form.submit();
                }
            });
        });
    </script>
@endsection
